home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-15 | 2.2 KB | 75 lines | [TEXT/CWIE] |
- // Common Stuff.h is a simple include file that holds a number of standard functions,
- // constants, and debugging macros. Anything that isn't likely to change from program
- // to program.
-
- #ifndef _COMMONSTUFF_
- #define _COMMONSTUFF_
-
- #pragma once
-
- /*********************************************************************************
- DEBUGGING and ERROR HANDLING MACROS
-
- These macros should be used to create code with proper error handling. In
- the debugging version of the macros, they dump a string to the debugger before
- dropping into the error handler.
-
- To turn debugging off, set the macro qDebugging to 0 before including Common Stuff.
-
- If an application wants to include special debugging code, the proper way to do this
- is with something like:
-
- #if qDebugging
- // do additional sanity checking here.
- #endif
-
- Note that this should only be additional sanity checking code and not eliminate all error
- checking code.
-
- *********************************************************************************/
- #define qDebugging 0
- #ifndef qDebugging
- #define qDebugging 0
- #endif
-
- #if qDebugging
- #define SIGNAL_ERROR(msg) {DebugStr(msg); goto error;}
- #else
- #define SIGNAL_ERROR(msg) {goto error;}
- #endif
-
- #define FAIL_NIL(y,msg) if (y == NULL) SIGNAL_ERROR(msg)
- #define FAIL_OSERR(y,msg) if (y != noErr) SIGNAL_ERROR(msg)
- #define FAIL_FALSE(y,msg) if (!y) SIGNAL_ERROR(msg)
-
-
- /*********************************************************************************
- QUICKDRAW
-
- This includes a standard set of functions and color constants to use in apps
- that use quickdraw. As written, this will only compile for C++, although the
- functions could be recast as macros.
-
- *********************************************************************************/
-
- #include <Quickdraw.h>
-
- const RGBColor kWhite = {0xFFFF, 0xFFFF, 0xFFFF};
- const RGBColor kBlack = {0x0000, 0x0000, 0x0000};
- const RGBColor kDarkBlue = {0x0000,0x0000,0x7000};
- const RGBColor kLtGrey = {0xC000,0xC000,0xC000};
- const RGBColor kMediumGrey = {0x7FFF,0x7FFF,0x7FFF};
-
- inline short RectWidth (const Rect& r) {
- return (r.right-r.left);
- }
-
- inline short RectHeight (const Rect& r) {
- return (r.bottom - r.top);
- }
-
- #endif /* _COMMONSTUFF_ */
-
-
-
-